<template>
	<view>
		<view class="flex align-c nav" :style="{paddingTop: statusBar + 'px'}">
			<image src="/static/home/back.png" mode="widthFix" class="nav_back_icon" @click="$back" />
			<view class="f1">
				<view class="nav_seach_box flex align-c">
					<image src="/static/home/seach-icon-gray.png" mode="aspectFill" class="nav_seach_icon" />
					<input type="text" class="input-box" v-model="keyword" @confirm="getList" placeholder="搜索用户昵称" placeholder-class="p-c">
				</view>
			</view>
		</view>
		
		<view :style="{height: statusBar + 44 +'px'}" />
		
		<view class="club_item" v-for="(v,i) in list" :key="i">
			<view class="between align-c">
				<view class="flex align-c">
					<image v-if="v.avator" :src="$img(v.avator)" mode="aspectFill" class="club_item_head" />
					<image v-else src="/static/head.png" mode="aspectFill" class="club_item_head" />
					<view class="club_item_name">
						<text v-if="v.name">{{ `${v.name}` }}</text>
					</view>
				</view>
				<view class="flex align-c into_font" v-if="v.has_contract == 1" @click="toContract(v)">
					<view class="status_name">查看合同</view>
					<image src="/static/home/into-gray.png" mode="widthFix" class="club_item_into" />
				</view>
				<view class="flex align-c into_font" v-else @click="toContract(v)">
					<view class="status_name red">上传合同</view>
					<image src="/static/home/into-red.png" mode="widthFix" class="goto_red" />
				</view>
			</view>
			<view class="between align-c club_statistics" :class="{'club_pb': v.status == 0}">
				<view class="">
					<text>打卡次数：</text>
					<text class="org">{{ v.clock_num || 0 }}</text>
				</view>
				<view class="">
					<text>私教课数：</text>
					<text class="org">{{ v.used_num || 0 }}</text>
					<text>/{{ v.course_num || 0 }}</text>
				</view>
				<view class="">
					<text>教练：</text>
					<text v-if="!v.coach.length">暂无教练</text>
					<text class="black" v-else>{{ v.coach[0].name}}</text>
				</view>
			</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				status: 0,
				statusBar: 0,
				keyword: "",
				show: false,
				list: [],
				page: 1,
				last_page: 1,
			}
		},
		onLoad() {
			this.getSystemInfo();
			
		},
		onShow() {
			this.shop_id = uni.getStorageSync('shopId');
			this.getList();
		},
		methods: {
			getSystemInfo() {
				uni.getSystemInfo({
					success: (e) => {
						this.statusBar = e.statusBarHeight
					}
				})
			},
			async getList() {
				let res = await this.$api.get('staff/user/list', {
					shop_id: this.shop_id,
					key: this.keyword,
				});
				if(res.code == 200) {
					if(this.page == 1) {
						this.list = res.data;
					}else {
						this.list.push(...res.data)
					}
				}
			},
			checkType(v) {
				this.typeIndex = v.type;
				this.show = false;
			},
			toContract(v) {
				if(v.has_contract == 1 || v.has_contract == 3) {
					this.$to(`/pages/home/member/member_inspect?id=${v.contract.id}&type=${v.has_contract}`)
				}else {
					this.$to(`/pages/home/member/member_upContract?id=${v.id}&type=${v.has_contract}`)
				}
			},
		}
	}
</script>

<style lang="scss" >
	page {
		box-sizing: border-box;
		background-color: #F7F7F7;
	}

	.nav {
		font-size: 24rpx;
		background-color: #FFF;
		height: 44px;
		line-height: 44px;
		position: fixed;
		left: 0;
		top: 0;
		right: 0;
		z-index: 999;
		&_back_icon {
			width: 15rpx;
			height: 27rpx;
			margin-left: 27rpx;
			margin-right: 20rpx;
		}
		&_seach_box {
			background-color: #F5F5F5;
			border-radius: 30rpx;
			padding: 12rpx 36rpx;
			margin: 0 27rpx;
			margin-left: 20rpx;
		}
		.input-box {
			font-size: 27rpx;
			flex: 1;
			margin: 0 20rpx;
		}
		&_seach_icon {
			width: 25rpx;
			height: 25rpx;
		}
		&_sort-icon {
			width: 29rpx;
			height: 29rpx;
			margin-right: 10rpx;
		}
		&_filter {
			width: 29rpx;
			height: 29rpx;
			margin-right: 10rpx;
			margin-left: 80rpx;
		}
		&__class__type {
			justify-content: flex-end;
			margin-right: 20rpx;
		}
		&_right {
			margin-right: 27rpx;
		}
	}
	
	.item_box {
		background-color: #F5F5F5;
		border-radius: 20rpx 20rpx 0 0;
		overflow: hidden;
		.item,.item_red {
			height: 98rpx;
			line-height: 98rpx;
			text-align: center;
			font-size: 32rpx;
			background-color: #FFF;
			border-bottom: 2rpx solid #F5F5F5;
		}
		.item_red {
			color: #F11A1A;
			margin-top: 20rpx;
		}
		.item:last-child {
			border-bottom: none;
		}
	}
	
	.club_item {
		margin: 20rpx 27rpx;
		padding: 25rpx;
		background-color: #fff;
		border-radius: 20rpx;
		font-size: 27rpx;
		color: #999;
		&_head {
			width: 60rpx;
			height: 60rpx;
			border-radius: 50%;
			margin-right: 16rpx;
		}
		.into_font {
			font-size: 24rpx;
		}
		&_into {
			width: 12rpx;
			height: 20rpx;
			margin-left: 12rpx;
		}
		.goto_red {
			width: 12rpx;
			height: 20rpx;
			margin-left: 8rpx;
		}
		&_name {
			font-weight: bold;
			color: #333333;
		}
		.status_name {
			font-size: 24rpx;
			font-weight: normal;
		}
		.club_statistics {
			padding: 32rpx 8rpx;
			padding-bottom: 16rpx;
			.black {
				color: #333333;
			}
			.org {
				color: #F17816;
			}
		}
		.club_pb {
			padding-bottom: 15rpx;
		}
		.btn {
			margin: 20rpx 0;
			margin-bottom: 0;
			padding: 0;
			height: 47rpx;
			line-height: 47rpx;
			min-width: 93rpx;
			text-align: center;
			font-size: 24rpx;
			background-color: #FFF;
			padding: 0 23rpx;
		}
	}
</style>
